﻿using MvcApplication.Entity;
using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MvcApplication.Data.Mapping
{
    public class Category_Mapping : EntityTypeConfiguration<Category>
    {
        public Category_Mapping()
        {
            this.HasKey(t => t.ID);
            this.ToTable("Category");

            this.HasMany(t => t.Posts).WithMany(t => t.Categories).Map(t =>
            {
                t.ToTable("PostCategory");
                t.MapLeftKey("CategoryID");
                t.MapRightKey("PostID");
            });
        }
    }
}
